package com.jxs.android.weixi;

import java.util.ArrayList;
import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public class Search_Result_HomePageAdapter extends PagerAdapter {
	public List<View> mData;
//	private List<Integer> mState;
//	private static final int StateLoading 	= 0;
//	private static final int StateDone 		= 1;
//	private static final int StateError 	= 2;

	public Search_Result_HomePageAdapter() {
		this.mData = new ArrayList<View>();
//		mState = new ArrayList<Integer>();
	}
	
	public void setData(List<View> data) {
		mData = data;
	}
	
	public void addItem(View item){
		mData.add(item);
	}
	
	public boolean updateItem (int index, View view){
		if (mData == null)
			return false;
		if (index >= 0 && index < mData.size()) {
			mData.set(index, view);
			return true;
		}
		return false;
	}
	
	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		View view = (View) object;
		container.removeView(view);
		view = null;
	}

	@Override
	public int getCount() {
		return mData.size();
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		container.addView(mData.get(position), 0);
		return mData.get(position);
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == (arg1);
	}

}